package com.yl.googleplayer_yl.utils;

import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;

import com.yl.googleplayer_yl.global.MyApp;

/**
 * Created by Administrator on 2016/10/30 0030.
 */

public class CommonUtils {
    public static String[] getArray(int id) {
        return MyApp.context.getResources().getStringArray(id);
    }

    public static void runOnUIThread(Runnable r) {
        MyApp.handler.post(r);
    }

    public static void runOnThread(Runnable r) {
        new Thread(r).start();

    }

    public static void removeSelfFromParent(View child){
        if(child!=null){
            ViewParent parent = child.getParent();
            if(parent!=null && parent instanceof ViewGroup){
                ViewGroup group = (ViewGroup) parent;
                group.removeView(child);//移除子View
            }
        }
    }
}
